package com.mrd.gtimp.business.entity;

import com.mrd.gtimp.base.entity.User;

import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;


/**
 * 经营单位临时信息
 * @author dengdc
 */
@Entity(name = "CDAMS_QP_COMPANYS_TEMP")
public class CompanyQpTemp implements Serializable {
    /**
     * 首次提交
     */
    public static final String FROM_FIRST_SUBMIT = "FIRST_SUBMIT";
    /**
     * 拒绝后提交
     */
    public static final String FROM_REFUSE_SUBMIT = "REFUSE_SUBMIT";

    /**
     * 审核通过
     */
    public static final String RESULT_PASS = "PASS";
    /**
     * 审核不通过
     */
    public static final String RESULT_REFUSE = "REFUSE";

    /**
     * 关闭
     */
    public static final String CLOSED_1 = "1";
    /**
     * 未关闭
     */
    public static final String CLOSED_0 = "0";


    @Id
    @GeneratedValue(generator = "paymentableGenerator")
    @GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
    private String id;

    /**
     * 单位编号
     */
    @Column(name = "company_code")
    private String companyCode;
    /**
     * 名称
     */
    @Column(name = "COMPANY_NAME")
    private String companyName;
    /**
     * 单位代码（18位社会统一代码）
     */
    @Column(name = "COMPANY_CO_UNITE")
    private String companyCoUnite;
    /**
     * 单位地址
     */
    @Column(name = "COMPANY_ADDRESS")
    private String companyAddress;
    /**
     * 联系电话
     */
    @Column(name = "COMPANY_PHONE")
    private String companyPhone;
    /**
     * 传真地址
     */
    @Column(name = "COMPANY_FAX")
    private String companyFax;

    //3.0

    /**
     * 归属公司
     */
    @Column(name = "refer_company_id")
    private String referenceCompanyId;

    /**
     * 提交时间
     */
    @Column(name = "submit_time_")
    private Date submitTime;

    /**
     * 提交人
     */
    @ManyToOne
    @JoinColumn(name = "submitor_")
    private User submitor;

    /**
     * 审核时间
     */
    @Column(name = "audit_time_")
    private Date auditTime;

    /**
     * 审核人
     */
    @ManyToOne
    @JoinColumn(name = "auditor_")
    private User auditor;

    /**
     * 审核结果， PASS：通过。 REFUSE:不通过(拒绝)
     */
    @Column(name = "audit_result_")
    private String auditResult;
    /**
     * 审核备注
     */
    @Column(name = "audit_remark_")
    private String auditRemark;
    /**
     * 是否关闭
     */
    @Column(name = "closed_")
    private String closed;

    /**
     * 来自用户提交还是审批驳回后的再次提交
     * 用户首次提交：FIRST_SUBMIT
     * 驳回后再次提交：REFUSE_SUBMIT
     */
    @Column(name = "from_")
    private String from;

    /**
     * 组号
     * 从提交到通过审批组号都不应该改变
     */
    @Column(name = "SERIES_NUM_")
    private String seriesNum;

    @Transient
    private List<String> cqps;

    /**
     * 生产组号
     */
    public static String generateSeriesNum(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String miLongString = String.valueOf(System.currentTimeMillis());
        int miLen = miLongString.length();
        return sdf.format(new Date()) + miLongString.subSequence(miLen - 3, miLen - 1);
    }

    // getter/setter
    public String getCompanyCode() {
        return companyCode;
    }

    public void setCompanyCode(String companyCode) {
        this.companyCode = companyCode;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getCompanyCoUnite() {
        return companyCoUnite;
    }

    public void setCompanyCoUnite(String companyCoUnite) {
        this.companyCoUnite = companyCoUnite;
    }

    public String getCompanyAddress() {
        return companyAddress;
    }

    public void setCompanyAddress(String companyAddress) {
        this.companyAddress = companyAddress;
    }

    public String getCompanyPhone() {
        return companyPhone;
    }

    public void setCompanyPhone(String companyPhone) {
        this.companyPhone = companyPhone;
    }

    public String getCompanyFax() {
        return companyFax;
    }

    public void setCompanyFax(String companyFax) {
        this.companyFax = companyFax;
    }

    public String getReferenceCompanyId() {
        return referenceCompanyId;
    }

    public void setReferenceCompanyId(String referenceCompanyId) {
        this.referenceCompanyId = referenceCompanyId;
    }

    public Date getSubmitTime() {
        return submitTime;
    }

    public void setSubmitTime(Date submitTime) {
        this.submitTime = submitTime;
    }

    public User getSubmitor() {
        return submitor;
    }

    public void setSubmitor(User submitor) {
        this.submitor = submitor;
    }

    public Date getAuditTime() {
        return auditTime;
    }

    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }

    public User getAuditor() {
        return auditor;
    }

    public void setAuditor(User auditor) {
        this.auditor = auditor;
    }

    public String getAuditResult() {
        return auditResult;
    }

    public void setAuditResult(String auditResult) {
        this.auditResult = auditResult;
    }

    public String getAuditRemark() {
        return auditRemark;
    }

    public void setAuditRemark(String auditRemark) {
        this.auditRemark = auditRemark;
    }

    public String getClosed() {
        return closed;
    }

    public void setClosed(String closed) {
        this.closed = closed;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getSeriesNum() {
        return seriesNum;
    }

    public void setSeriesNum(String seriesNum) {
        this.seriesNum = seriesNum;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<String> getCqps() {
        return cqps;
    }

    public void setCqps(List<String> cqps) {
        this.cqps = cqps;
    }

    @Override
    public String toString() {
        return "CompanyQpTemp{" +
                "id='" + id + '\'' +
                ", companyCode='" + companyCode + '\'' +
                ", companyName='" + companyName + '\'' +
                ", companyCoUnite='" + companyCoUnite + '\'' +
                ", companyAddress='" + companyAddress + '\'' +
                ", companyPhone='" + companyPhone + '\'' +
                ", companyFax='" + companyFax + '\'' +
                ", referenceCompanyId='" + referenceCompanyId + '\'' +
                ", submitTime=" + submitTime +
                ", submitor=" + submitor +
                ", auditTime=" + auditTime +
                ", auditor=" + auditor +
                ", auditResult='" + auditResult + '\'' +
                ", auditRemark='" + auditRemark + '\'' +
                ", closed='" + closed + '\'' +
                ", from='" + from + '\'' +
                ", seriesNum='" + seriesNum + '\'' +
                '}';
    }
}

